<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>navSelect</title>
    <style>
        #div1{
            width: 100px;
            height: 150px;
            background: #ccc;
            display: none;
        }
    </style>
    <script>
        window.onload = function () {
          var oBtn = document.getElementById('btn1');
          var oDiv = document.getElementById('div1');
          oBtn.onclick = function (e) {
            if(oDiv.style.display == 'block'){
              oDiv.style.display = 'none';
            }else{
              oDiv.style.display = 'block';
            }
            e.cancelBubble = true
          }
          document.onclick = function () {
            oDiv.style.display = 'none'
          }
        }
    </script>
</head>
<body>
<input id="btn1" type="button" value="显示">
<div id="div1"></div>
</body>
</html>